<?php
//
//  MusicTheory
//
//  Created by Jules Bernable on 2007-07-26.
//  Copyright (c) 2007  __LaForceMolle__. All rights reserved.
//
//includes
//
//
class MusicTheory {
	//
	/********************************************************************************
	******************************** Propriétés *************************************
	********************************************************************************/
	//
	var $ALTERATIONS;
	var $TONES;
	var $INTERVALS;
	var $MODES;
	//
	/********************************************************************************
	********************************** Constructeur *********************************
	********************************************************************************/
	// constructeur appelé par php5.
	function __construct(){
		//
		/************************************************************************/
		// THE ALTERATIONS
		// (retrieves HTML entities for the alterations symbols)
		//
		$this->ENTITIES = array(
			'alterations' => array(
				'n' 	=> '&#9838;',
				'##' 	=> '&#119082;',
				'#' 	=> '&#9839;',
				'bb'	=> '&#119083;',
				'b' 	=> '&#9837;',
			),
			'short_symbols' => array(
				'Maj7'	=> '&#916;',
				'min7b5' => '&#216;',
				'dim' => 'o',
				'min' => '&#8722;',
				'#5' => '+'
			)
		);
		//
		/************************************************************************/
		// Basic Tones
		$this->BASIC_TONES = array('C', 'D', 'E', 'F', 'G', 'A', 'B');
		//
		/************************************************************************/
		// THE TONES
		//
		$this->TONES[-19] = 'B##';
		$this->TONES[-18] = 'E##';
		$this->TONES[-17] = 'A##';
		$this->TONES[-16] = 'D##';
		$this->TONES[-15] = 'G##';
		$this->TONES[-14] = 'C##';
		$this->TONES[-13] = 'F##';
		$this->TONES[-12] = 'B#';
		$this->TONES[-11] = 'E#';
		$this->TONES[-10] = 'A#';
		$this->TONES[-9] = 'D#';
		$this->TONES[-8] = 'G#';
		$this->TONES[-7] = 'C#';
		$this->TONES[-6] = 'F#';
		$this->TONES[-5] = 'B';
		$this->TONES[-4] = 'E';
		$this->TONES[-3] = 'A';
		$this->TONES[-2] = 'D';
		$this->TONES[-1] = 'G';
		$this->TONES[0] = 'C';
		$this->TONES[1] = 'F';
		$this->TONES[2] = 'Bb';
		$this->TONES[3] = 'Eb';
		$this->TONES[4] = 'Ab';
		$this->TONES[5] = 'Db';
		$this->TONES[6] = 'Gb';
		$this->TONES[7] = 'Cb';
		$this->TONES[8] = 'Fb';
		$this->TONES[9] = 'Bbb';
		$this->TONES[10] = 'Ebb';
		$this->TONES[11] = 'Abb';
		$this->TONES[12] = 'Dbb';
		$this->TONES[13] = 'Gbb';
		$this->TONES[14] = 'Cbb';
		$this->TONES[15] = 'Fbb';
		$this->TONES[666] = 'This Note/Chord does not exists !';
		//
		/************************************************************************/
		// THE INTERVALS
		//
		$this->INTERVALS = array(
			/////////////////////// steps
			'half_step' => -7,
			'whole_step' => 2,
			/////////////////////// 1st Octava
			'min_second' => 5,
			'maj_second' => -2,
			'aug_second' => -9,
			//
			'dim_third' => 10,
			'min_third' => 3,
			'maj_third' => -4,
			//
			'dim_fourth' => 8,
			'perf_fourth' => 1,
			'aug_fourth' => -6,
			//
			'dim_fifth' => 6,
			'perf_fifth' => -1,
			'aug_fifth' => -8,
			//
			'min_sixth' => 4,
			'maj_sixth' => -3,
			//
			'dim_seventh' => 9,
			'min_seventh' => 2,
			'maj_seventh' => -5,
			/////////////////////// 2nd Octava
			'min_ninth' => 5,
			'maj_ninth' => -2,
			'aug_ninth'=> -9,
			//
			'eleventh'=> 1,
			'aug_eleventh'=> -6,
			//
			'maj_thirteenth' => -3,
			'min_thirteenth' => 4,
			/////////////////////// Enharmonic
			'enharmonic' => 12
		);
		//
		/************************************************************************/
		// THE EXTENSIONS
		//
		$this->EXTENSIONS = array(
			'b9' => $this->INTERVALS['min_ninth'],
			'9' => $this->INTERVALS['maj_ninth'],
			'#9' => $this->INTERVALS['aug_ninth'],
			//
			'11' => $this->INTERVALS['eleventh'],
			'#11' =>$this->INTERVALS['aug_eleventh'],
			//
			'b13' => $this->INTERVALS['min_thirteenth'],
			'13' => $this->INTERVALS['maj_thirteenth']
		);
		//
		/************************************************************************/
		// THE CHORDS
		//
		$this->CHORDS = array(
			//'maj' => array(0, $this->INTERVALS['maj_third'], $this->INTERVALS['perf_fifth']),
			//'min' => array(0, $this->INTERVALS['min_third'], $this->INTERVALS['perf_fifth']),
			//'aug' => array(0, $this->INTERVALS['maj_third'], $this->INTERVALS['aug_fifth']),
			//'dim' => array(0, $this->INTERVALS['maj_third'], $this->INTERVALS['dim_fifth']),
			//'sus4' => array(0, $this->INTERVALS['perf_fourth'], $this->INTERVALS['perf_fifth']),
			//'sus2' => array(0, $this->INTERVALS['maj_second'], $this->INTERVALS['perf_fifth']),
			'Maj7' => array(0, $this->INTERVALS['maj_third'], $this->INTERVALS['perf_fifth'], $this->INTERVALS['maj_seventh']),	// => '&#916;'
			'Maj7#5' => array(0, $this->INTERVALS['maj_third'], $this->INTERVALS['aug_fifth'], $this->INTERVALS['maj_seventh']), // => '&#916;+'
			//'Maj7b5' => array(0, $this->INTERVALS['maj_third'], $this->INTERVALS['dim_fifth'], $this->INTERVALS['maj_seventh']), // => '&#916;+4'
			//'6' => array(0, $this->INTERVALS['maj_third'], $this->INTERVALS['perf_fifth'], $this->INTERVALS['maj_sixth']),
			'7' => array(0, $this->INTERVALS['maj_third'], $this->INTERVALS['perf_fifth'], $this->INTERVALS['min_seventh']),
			'7#5' => array(0, $this->INTERVALS['maj_third'], $this->INTERVALS['aug_fifth'], $this->INTERVALS['min_seventh']), // => '7+'
			'7b5' => array(0, $this->INTERVALS['maj_third'], $this->INTERVALS['dim_fifth'], $this->INTERVALS['min_seventh']),
			// minor
			'minMaj7' => array(0, $this->INTERVALS['min_third'], $this->INTERVALS['perf_fifth'], $this->INTERVALS['maj_seventh']), // => '-&#916;'
			//'minMaj7#5' => array(0, $this->INTERVALS['min_third'], $this->INTERVALS['aug_fifth'], $this->INTERVALS['maj_seventh']), // => '-&#916;+'
			//'minMaj7b5' => array(0, $this->INTERVALS['min_third'], $this->INTERVALS['dim_fifth'], $this->INTERVALS['maj_seventh']), // => '-&#916;b5'
			'min7' => array(0, $this->INTERVALS['min_third'], $this->INTERVALS['perf_fifth'], $this->INTERVALS['min_seventh']), // => '-7'
			//'min7#5' => array(0, $this->INTERVALS['min_third'], $this->INTERVALS['aug_fifth'], $this->INTERVALS['min_seventh']), // =>'-7+'
			'min7b5' => array(0, $this->INTERVALS['min_third'], $this->INTERVALS['dim_fifth'], $this->INTERVALS['min_seventh']), // => '-7&#216;' == 'ø'
			'min6' => array(0, $this->INTERVALS['min_third'], $this->INTERVALS['perf_fifth'], $this->INTERVALS['maj_sixth']),
			// diminished
			//'dimMaj7' => array(0, $this->INTERVALS['min_third'], $this->INTERVALS['dim_fifth'], $this->INTERVALS['maj_seventh']), // => 'o&#916;'
			'dim7' => array(0, $this->INTERVALS['min_third'], $this->INTERVALS['dim_fifth'], $this->INTERVALS['dim_seventh']), // => 'o'
			//'dimbb7' => array(), // =>'obb7'
			//suspended
			//'7sus4' => array(0, $this->INTERVALS['perf_fourth'], $this->INTERVALS['perf_fifth'], $this->INTERVALS['min_seventh']),
			//'7sus4b5' => array(0, $this->INTERVALS['perf_fourth'], $this->INTERVALS['dim_fifth'], $this->INTERVALS['min_seventh']),
			// more
			//'9' => array(0, $this->INTERVALS['maj_third'], $this->INTERVALS['perf_fifth'], $this->INTERVALS['min_seventh'], $this->INTERVALS['maj_second']),
			//'13' => array(0, $this->INTERVALS['maj_third'], $this->INTERVALS['perf_fifth'], $this->INTERVALS['min_seventh'], $this->INTERVALS['maj_second'], $this->INTERVALS['maj_sixth']),
			//'alt' => array(0, $this->INTERVALS['maj_third'], $this->INTERVALS['aug_fifth'], $this->INTERVALS['min_seventh'], $this->INTERVALS['min_third'], $this->INTERVALS['aug_fourth'], $this->INTERVALS['min_sixth']),
			// case of inexistant chord
			'X' => array(666)
		);
		//
		/************************************************************************/
		// THE MODES
		//
		$this->MODES = array(
			/*******************************************/
			///////////////////////////// Major Modes //
			/******************************************/
			'ionian' => array(
				'parent' => 'ionian',
				'degree' => 1,
				'offset' => 0,
				'degrees' => array(
					'roots' => array(
						0,
						$this->INTERVALS['maj_second'],
						$this->INTERVALS['maj_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['maj_sixth'],
						$this->INTERVALS['maj_seventh']
					),
					'chords' => array(
						'Maj7',
						'min7',
						'min7',
						'Maj7',
						'7',
						'min7',
						'min7b5'
					),
					'extensions' => array(
						array($this->EXTENSIONS['9'], $this->EXTENSIONS['13']),
						array($this->EXTENSIONS['9'], $this->EXTENSIONS['11'], $this->EXTENSIONS['13']),
						array($this->EXTENSIONS['b9'], $this->EXTENSIONS['11'], $this->EXTENSIONS['b13']),
						array($this->EXTENSIONS['9'], $this->EXTENSIONS['#1'], $this->EXTENSIONS['13']),
						array($this->EXTENSIONS['9'], $this->EXTENSIONS['13']),
						array($this->EXTENSIONS['9'], $this->EXTENSIONS['11'], $this->EXTENSIONS['b13']),
						array($this->EXTENSIONS['b9'], $this->EXTENSIONS['11'], $this->EXTENSIONS['b13'])
					),
					'cadential_notes' => array(3, 7),
					'cadential_chords' => array(5)
				)
			),
			'dorian' => array(
				'parent' => 'ionian',
				'degree' => 2,
				'offset' => -2,
				'degrees' => array(
					'roots' => array(
						0,
						$this->INTERVALS['maj_second'],
						$this->INTERVALS['min_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['maj_sixth'],
						$this->INTERVALS['min_seventh']
					),
					'chords' => array(
						'min7',
						'min7',
						'Maj7',
						'7',
						'min7',
						'min7b5',
						'Maj7'
					),
					'cadential_notes' => array(6),
					'cadential_chords' => array(2, 4, 7)
				)
			),
			'phrygian' => array(
				'parent' => 'ionian',
				'degree' => 3,
				'offset' => -4,
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['min_second'],
						$this->INTERVALS['min_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['min_sixth'],
						$this->INTERVALS['min_seventh']
					),
					'chords' => array(
						'min7',
						'Maj7',
						'7',
						'min7',
						'min7b5',
						'Maj7',
						'min7'
					),
					'cadential_notes' => array(2),
					'cadential_chords' => array(2, 3, 7)
				)
			),
			'lydian' => array(
				'parent' => 'ionian',
				'degree' => 4,
				'offset' => 1,
				'degrees' => array(
					'roots' => array(
						0,
						$this->INTERVALS['maj_second'],
						$this->INTERVALS['maj_third'],
						$this->INTERVALS['aug_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['maj_sixth'],
						$this->INTERVALS['maj_seventh']
					),
					'chords' => array(
						'Maj7',
						'7',
						'min7',
						'min7b5',
						'Maj7',
						'min7',
						'min7'
					),
					'cadential_notes' => array(4),
					'cadential_chords' => array(2, 5, 7)
				)
			),
			'mixolydian' => array(
				'parent' => 'ionian',
				'degree' => 5,
				'offset' => -1,
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['maj_second'],
						$this->INTERVALS['maj_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['maj_sixth'],
						$this->INTERVALS['min_seventh']
					),
					'chords' => array(
						'7',
						'min7',
						'min7b5',
						'Maj7',
						'min7',
						'min7',
						'Maj7'
					),
					'cadential_notes' => array(7),
					'cadential_chords' => array(5, 7)
				)
			),
			'Aeolian' => array(
				'parent' => 'ionian',
				'degree' => 6,
				'offset' => -3,
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['maj_second'],
						$this->INTERVALS['min_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['min_sixth'],
						$this->INTERVALS['min_seventh']
					),
					'chords' => array(
						'min7',
						'min7b5',
						'Maj7',
						'min7',
						'min7',
						'Maj7',
						'7'
					),
					'cadential_notes' => array(6),
					'cadential_chords' => array(4, 6, 7)
				)
			),
			'locrian' => array(
				'parent' => 'ionian',
				'degree' => 7,
				'offset' => -5,
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['min_second'],
						$this->INTERVALS['min_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['dim_fifth'],
						$this->INTERVALS['min_sixth'],
						$this->INTERVALS['min_seventh']
					),
					'chords' => array(
						'7sus4b5',
						'Maj7',
						'min7',
						'min7',
						'Maj7',
						'7',
						'min7'
					),
					'cadential_notes' => array(2, 5),
					'cadential_chords' => array(2, 3, 5, 7)
				)
			),
			/***************************************************/
			///////////////////////////// Melodic Minor Modes //
			/***************************************************/
			'melodic minor' => array(
				'parent' => 'melodic minor',
				'degree' => 1,
				'offset' => 0,
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['maj_second'],
						$this->INTERVALS['min_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['maj_sixth'],
						$this->INTERVALS['maj_seventh']
					),
					'chords' => array(
						'minMaj7',
						'min7',
						'Maj7#5',
						'7',
						'7',
						'min7b5',
						'dim7'
					),
					'extensions' => array(
						array($this->EXTENSIONS['9'], $this->EXTENSIONS['11'], $this->EXTENSIONS['13']),
						array($this->EXTENSIONS['b9'], $this->EXTENSIONS['11'], $this->EXTENSIONS['13']),
						array($this->EXTENSIONS['9'], $this->EXTENSIONS['#11'], $this->EXTENSIONS['13']),
						array($this->EXTENSIONS['9'], $this->EXTENSIONS['#11'], $this->EXTENSIONS['13']),
						array($this->EXTENSIONS['9'], $this->EXTENSIONS['b13']),
						array($this->EXTENSIONS['9'], $this->EXTENSIONS['11'], $this->EXTENSIONS['b13']),
						array($this->EXTENSIONS['b9'], $this->EXTENSIONS['#9'], $this->EXTENSIONS['b13'])
					),
					'cadential_notes' => array(3, 7),
					'cadential_chords' => array(5, 7)
				)
			),
			'phrygian n6' => array(
				'parent' => 'melodic minor',
				'degree' => 2,
				'offset' => $this->INTERVALS['maj_second'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['min_second'],
						$this->INTERVALS['min_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['maj_sixth'],
						$this->INTERVALS['min_seventh']
					),
					'chords' => array(
						'min7',
						'Maj7#5',
						'7',
						'7',
						'min7b5',
						'dim7',
						'minMaj7'
					),
					'cadential_notes' => array(2, 6),
					'cadential_chords' => array(2, 7)
				)
			),
			'lydian augmented' => array(
				'parent' => 'melodic minor',
				'degree' => 3,
				'offset' => $this->INTERVALS['min_third'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['maj_second'],
						$this->INTERVALS['maj_third'],
						$this->INTERVALS['aug_fourth'],
						$this->INTERVALS['aug_fifth'],
						$this->INTERVALS['maj_sixth'],
						$this->INTERVALS['maj_seventh']
					),
					'chords' => array(
						'Maj7#5',
						'7',
						'7',
						'min7b5',
						'dim7',
						'minMaj7',
						'min7'
					),
					'cadential_notes' => array(4, 5),
					'cadential_chords' => array(2, 7)
				)
			),
			'lydian b7' => array(
				'parent' => 'melodic minor',
				'degree' => 4,
				'offset' => $this->INTERVALS['perf_fourth'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['maj_second'],
						$this->INTERVALS['maj_third'],
						$this->INTERVALS['aug_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['maj_sixth'],
						$this->INTERVALS['min_seventh']
					),
					'chords' => array(
						'7',
						'7',
						'min7b5',
						'dim7',
						'minMaj7',
						'min7',
						'Maj7#5'
					),
					'cadential_notes' => array(4, 7),
					'cadential_chords' => array(2, 5, 7)
				)
			),
			'mixolydian b6' => array(
				'parent' => 'melodic minor',
				'degree' => 5,
				'offset' => $this->INTERVALS['perf_fifth'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['maj_second'],
						$this->INTERVALS['maj_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['min_sixth'],
						$this->INTERVALS['min_seventh']
					),
					'chords' => array(
						'7',
						'min7b5',
						'dim7',
						'minMaj7',
						'min7',
						'Maj7#5',
						'7'
					),
					'cadential_notes' => array(6, 7),
					'cadential_chords' => array(4, 6, 7)
				)
			),
			'locrian n2' => array(
				'parent' => 'melodic minor',
				'degree' => 6,
				'offset' => $this->INTERVALS['maj_sixth'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['maj_second'],
						$this->INTERVALS['min_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['dim_fifth'],
						$this->INTERVALS['min_sixth'],
						$this->INTERVALS['min_seventh']
					),
					'chords' => array(						
						'min7b5',
						'dim7',
						'minMaj7',
						'min7',
						'Maj7#5',
						'7',
						'7'
					),
					'cadential_notes' => array(2, 5),
					'cadential_chords' => array(3, 5, 7)
				)
			),
			'super locrian' => array(
				'parent' => 'melodic minor',
				'degree' => 7,
				'offset' => $this->INTERVALS['maj_seventh'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['min_second'],
						$this->INTERVALS['min_third'],
						$this->INTERVALS['dim_fourth'],
						$this->INTERVALS['dim_fifth'],
						$this->INTERVALS['min_sixth'],
						$this->INTERVALS['min_seventh']
					),
					'chords' => array(
						'dim7',
						'minMaj7',
						'min7',
						'Maj7#5',
						'7',
						'7',
						'min7b5',
					),
					'cadential_notes' => array(2, 4, 5),
					'cadential_chords' => array(2, 5)
				)
			),
			/***************************************************/
			//////////////////////////// Harmonic Minor Modes //
			/***************************************************/
			'harmonic minor' => array(
				'parent' => 'harmonic minor',
				'degree' => 1,
				'offset' => 0,
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['maj_second'],
						$this->INTERVALS['min_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['min_sixth'],
						$this->INTERVALS['maj_seventh']
					),
					'chords' => array(
						'minMaj7',
						'min7b5',
						'Maj7#5',
						'min7',
						'7',
						'Maj7',
						'dim7',
					),
					'extensions' => array(
						array($this->EXTENSIONS['9'], $this->EXTENSIONS['11'], $this->EXTENSIONS['b13']),
						array($this->EXTENSIONS['b9'], $this->EXTENSIONS['11'], $this->EXTENSIONS['13']),
						array($this->EXTENSIONS['9'], $this->EXTENSIONS['13']),
						array($this->EXTENSIONS['9'], $this->EXTENSIONS['#11'], $this->EXTENSIONS['13']),
						array($this->EXTENSIONS['b9'], $this->EXTENSIONS['b13']),
						array($this->EXTENSIONS['#9'], $this->EXTENSIONS['#11'], $this->EXTENSIONS['13']),
						array($this->EXTENSIONS['b9'], $this->EXTENSIONS['#9'], $this->EXTENSIONS['b13'])
					),
					'cadential_notes' => array(3, 6, 7),
					'cadential_chords' => array(5, 7)
				)
			),
			'locrian n6' => array(
				'parent' => 'harmonic minor',
				'degree' => 2,
				'offset' => $this->INTERVALS['maj_second'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['min_second'],
						$this->INTERVALS['min_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['dim_fifth'],
						$this->INTERVALS['maj_sixth'],
						$this->INTERVALS['min_seventh']
					),
					'chords' => array(						
						'min7b5',
						'Maj7#5',
						'min7',
						'7',
						'Maj7',
						'dim7',
						'minMaj7'
					),
					'cadential_notes' => array(2, 5, 6),
					'cadential_chords' => array(2, 5, 7)
				)
			),
			'ionian #5' => array(
				'parent' => 'harmonic minor',
				'degree' => 3,
				'offset' => $this->INTERVALS['min_third'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['maj_second'],
						$this->INTERVALS['maj_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['aug_fifth'],
						$this->INTERVALS['maj_sixth'],
						$this->INTERVALS['maj_seventh']
					),
					'chords' => array(						
						'Maj7#5',
						'min7',
						'7',
						'Maj7',
						'dim7',
						'minMaj7',
						'min7b5'
					),
					'cadential_notes' => array(5),
					'cadential_chords' => array(1)
				)
			),
			'dorian #4' => array(
				'parent' => 'harmonic minor',
				'degree' => 4,
				'offset' => $this->INTERVALS['perf_fourth'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['maj_second'],
						$this->INTERVALS['min_third'],
						$this->INTERVALS['aug_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['maj_sixth'],
						$this->INTERVALS['min_seventh']
					),
					'chords' => array(						
						'min7',
						'7',
						'Maj7',
						'dim7',
						'minMaj7',
						'min7b5',
						'Maj7#5'
					),
					'cadential_notes' => array(4, 6),
					'cadential_chords' => array(2, 7)
				)
			),
			'phrygian major' => array(
				'parent' => 'harmonic minor',
				'degree' => 5,
				'offset' => $this->INTERVALS['perf_fifth'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['min_second'],
						$this->INTERVALS['maj_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['min_sixth'],
						$this->INTERVALS['min_seventh']
					),
					'chords' => array(						
						'7',
						'Maj7',
						'dim7',
						'minMaj7',
						'min7b5',
						'Maj7#5',
						'min7',
					),
					'cadential_notes' => array(2, 3),
					'cadential_chords' => array(2, 7)
				)
			),
			'lydian #2' => array(
				'parent' => 'harmonic minor',
				'degree' => 6,
				'offset' => $this->INTERVALS['min_sixth'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['aug_second'],
						$this->INTERVALS['maj_third'],
						$this->INTERVALS['aug_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['maj_sixth'],
						$this->INTERVALS['maj_seventh']
					),
					'chords' => array(						
						'Maj7',
						'dim7',
						'minMaj7',
						'min7b5',
						'Maj7#5',
						'min7',
						'7'
					),
					'cadential_notes' => array(2, 4),
					'cadential_chords' => array(5, 7)
				)
			),
			'super locrian bb7' => array(
				'parent' => 'harmonic minor',
				'degree' => 7,
				'offset' => $this->INTERVALS['maj_seventh'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['min_second'],
						$this->INTERVALS['min_third'],
						$this->INTERVALS['dim_fourth'],
						$this->INTERVALS['dim_fifth'],
						$this->INTERVALS['min_sixth'],
						$this->INTERVALS['dim_seventh']
					),
					'chords' => array(						
						'dim7',
						'minMaj7',
						'min7b5',
						'Maj7#5',
						'min7',
						'7',
						'Maj7'
					),
					'cadential_notes' => array(2, 4, 5, 7),
					'cadential_chords' => array(5)
				)
			),
			/*******************************************/
			//////////////////// Harmonic Major Modes //
			/******************************************/
			'harmonic major' => array(
				'parent' => 'harmonic major',
				'degree' => 1,
				'offset' => 0,
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['maj_second'],
						$this->INTERVALS['maj_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['min_sixth'],
						$this->INTERVALS['maj_seventh']
					),
					'chords' => array(						
						'Maj7',
						'min7b5',
						'min7',
						'minMaj7',
						'7',
						'Maj7#5',
						'dim7',
					),
					'extensions' => array(
						array($this->EXTENSIONS['9'], $this->EXTENSIONS['b13']),
						array($this->EXTENSIONS['9'], $this->EXTENSIONS['11'], $this->EXTENSIONS['13']),
						array($this->EXTENSIONS['b9'], $this->EXTENSIONS['#9'], $this->EXTENSIONS['b13']),
						array($this->EXTENSIONS['9'], $this->EXTENSIONS['#11'], $this->EXTENSIONS['13']),
						array($this->EXTENSIONS['b9'], $this->EXTENSIONS['13']),
						array($this->EXTENSIONS['#9'], $this->EXTENSIONS['#11'], $this->EXTENSIONS['13']),
						array($this->EXTENSIONS['b9'], $this->EXTENSIONS['11'], $this->EXTENSIONS['b13'])
					),
					'cadential_notes' => array(3, 6, 7),
					'cadential_chords' => array(5, 7)
				)
			),
			'dorian b5' => array(
				'parent' => 'harmonic major',
				'degree' => 2,
				'offset' => $this->INTERVALS['maj_second'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['maj_second'],
						$this->INTERVALS['min_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['dim_fifth'],
						$this->INTERVALS['maj_sixth'],
						$this->INTERVALS['min_seventh']
					),
					'chords' => array(						
						'min7b5',
						'min7',
						'minMaj7',
						'7',
						'Maj7#5',
						'dim7',
						'Maj7'
					),
					'cadential_notes' => array(2, 5, 6),
					'cadential_chords' => array(2, 7)
				)
			),
			'super locrian n5' => array(
				'parent' => 'harmonic major',
				'degree' => 2,
				'offset' => $this->INTERVALS['maj_third'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['min_second'],
						$this->INTERVALS['min_third'],
						$this->INTERVALS['dim_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['min_sixth'],
						$this->INTERVALS['min_seventh']
					),
					'chords' => array(
						'min7',
						'minMaj7',
						'7',
						'Maj7#5',
						'dim7',
						'Maj7',
						'min7b5'
					),
					'cadential_notes' => array(4, 5),
					'cadential_chords' => array(2, 4, 6)
				)
			),
			'melodic minor #4' => array(
				'parent' => 'harmonic major',
				'degree' => 4,
				'offset' => $this->INTERVALS['perf_fourth'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['maj_second'],
						$this->INTERVALS['min_third'],
						$this->INTERVALS['aug_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['maj_sixth'],
						$this->INTERVALS['maj_seventh']
					),
					'chords' => array(						
						'minMaj7',
						'7',
						'Maj7#5',
						'dim7',
						'Maj7',
						'min7b5',
						'min7'
					),
					'cadential_notes' => array(3, 4),
					'cadential_chords' => array(2, 5, 7)
				)
			),
			'mixolydian b2' => array(
				'parent' => 'harmonic major',
				'degree' => 5,
				'offset' => $this->INTERVALS['perf_fifth'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['min_second'],
						$this->INTERVALS['maj_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['maj_sixth'],
						$this->INTERVALS['min_seventh']
					),
					'chords' => array(						
						'7',
						'Maj7#5',
						'dim7',
						'Maj7',
						'min7b5',
						'min7',
						'minMaj7'
					),
					'cadential_notes' => array(2, 7),
					'cadential_chords' => array(2, 7)
				)
			),
			'lydian #5 #2' => array(
				'parent' => 'harmonic major',
				'degree' => 6,
				'offset' => $this->INTERVALS['min_sixth'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['aug_second'],
						$this->INTERVALS['maj_third'],
						$this->INTERVALS['aug_fourth'],
						$this->INTERVALS['aug_fifth'],
						$this->INTERVALS['maj_sixth'],
						$this->INTERVALS['maj_seventh']
					),
					'chords' => array(						
						'Maj7#5',
						'dim7',
						'Maj7',
						'min7b5',
						'min7',
						'minMaj7',
						'7'
					),
					'cadential_notes' => array(2, 5, 4),
					'cadential_chords' => array(5)
				)
			),
			'locrian bb7' => array(
				'parent' => 'harmonic major',
				'degree' => 7,
				'offset' => $this->INTERVALS['maj_seventh'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['min_second'],
						$this->INTERVALS['min_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['dim_fifth'],
						$this->INTERVALS['min_sixth'],
						$this->INTERVALS['dim_seventh']
					),
					'chords' => array(						
						'dim7',
						'Maj7',
						'min7b5',
						'min7',
						'minMaj7',
						'7',
						'Maj7#5'
					),
					'cadential_notes' => array(5, 7),
					'cadential_chords' => array(5)
				)
			),
			/*******************************************/
			/////////////////// Double Harmonic Modes //
			/******************************************/
			'double harmonic' => array(
				'parent' => 'double harmonic',
				'degree' => 1,
				'offset' => 0,
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['min_second'],
						$this->INTERVALS['maj_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['min_sixth'],
						$this->INTERVALS['maj_seventh']
					),
					'chords' => array(						
						'Maj7',
						'Maj7',
						'min6',
						'minMaj7',
						'7b5',
						'Maj7#5',
						'X'
					),
					'extensions' => array(
						array($this->EXTENSIONS['b13']),
						array($this->EXTENSIONS['#9'], $this->EXTENSIONS['#11']),
						array(),
						array($this->EXTENSIONS['9'], $this->EXTENSIONS['#11'], $this->EXTENSIONS['b13']),
						array($this->EXTENSIONS['b9'], $this->EXTENSIONS['13']),
						array($this->EXTENSIONS['#9'], $this->EXTENSIONS['13']),
						array()
					),
					'cadential_notes' => array(2, 3, 7),
					'cadential_chords' => array(2)
				)
			),
			'lydian #2 #6' => array(
				'parent' => 'double harmonic',
				'degree' => 2,
				'offset' => $this->INTERVALS['min_second'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['aug_second'],
						$this->INTERVALS['maj_third'],
						$this->INTERVALS['aug_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['aug_sixth'],
						$this->INTERVALS['maj_seventh']
					),
					'chords' => array(						
						'Maj7',
						'min6',
						'minMaj7',
						'7b5',
						'Maj7#5',
						'X',
						'Maj7'
					),
					'cadential_notes' => array(2, 4, 6),
					'cadential_chords' => array(2, 7)
				)
			),
			'super locrian n5 bb7' => array(
				'parent' => 'double harmonic',
				'degree' => 3,
				'offset' => $this->INTERVALS['maj_third'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['min_second'],
						$this->INTERVALS['min_third'],
						$this->INTERVALS['dim_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['min_sixth'],
						$this->INTERVALS['dim_seventh']
					),
					'chords' => array(						
						'min6',
						'minMaj7',
						'7b5',
						'Maj7#5',
						'X',
						'Maj7',
						'Maj7'
					),
					'cadential_notes' => array(4, 5, 7),
					'cadential_chords' => array(3, 6, 7)
				)
			),
			'hungarian minor' => array(
				'parent' => 'double harmonic',
				'degree' => 4,
				'offset' => $this->INTERVALS['perf_fourth'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['maj_second'],
						$this->INTERVALS['min_third'],
						$this->INTERVALS['aug_fourth'],
						$this->INTERVALS['perf_fifth'],
						$this->INTERVALS['min_sixth'],
						$this->INTERVALS['maj_seventh']
					),
					'chords' => array(						
						'minMaj7',
						'7b5',
						'Maj7#5',
						'X',
						'Maj7',
						'Maj7',
						'min6'
					),
					'cadential_notes' => array(4, 6),
					'cadential_chords' => array(7)
				)
			),
			'oriental' => array(
				'parent' => 'double harmonic',
				'degree' => 5,
				'offset' => $this->INTERVALS['perf_fifth'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['min_second'],
						$this->INTERVALS['maj_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['dim_fifth'],
						$this->INTERVALS['maj_sixth'],
						$this->INTERVALS['min_seventh']
					),
					'chords' => array(						
						'7b5',
						'Maj7#5',
						'X',
						'Maj7',
						'Maj7',
						'min6',
						'minMaj7'
					),
					'cadential_notes' => array(3, 5),
					'cadential_chords' => array(6)
				)
			),
			'ionien #2 #5' => array(
				'parent' => 'double harmonic',
				'degree' => 6,
				'offset' => $this->INTERVALS['min_sixth'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['aug_second'],
						$this->INTERVALS['maj_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['aug_fifth'],
						$this->INTERVALS['maj_sixth'],
						$this->INTERVALS['maj_seventh']
					),
					'chords' => array(						
						'Maj7#5',
						'X',
						'Maj7',
						'Maj7',
						'min6',
						'minMaj7',
						'7b5'
					),
					'cadential_notes' => array(2, 5),
					'cadential_chords' => array(3, 5, 7)
				)
			),
			'locrien bb3 bb7' => array(
				'parent' => 'double harmonic',
				'degree' => 7,
				'offset' => $this->INTERVALS['maj_seventh'],
				'degrees' => array(
					'roots' => array(
						0, 
						$this->INTERVALS['min_second'],
						$this->INTERVALS['dim_third'],
						$this->INTERVALS['perf_fourth'],
						$this->INTERVALS['dim_fifth'],
						$this->INTERVALS['min_sixth'],
						$this->INTERVALS['dim_seventh']
					),
					'chords' => array(						
						'X',
						'Maj7',
						'Maj7',
						'min6',
						'minMaj7',
						'7b5',
						'Maj7#5'
					),
					'cadential_notes' => array(3, 5, 7),
					'cadential_chords' => array(3, 5)
				)
			)
		);
		//
		$this->PARENT_MODES = array(
			'ionian' => $this->MODES['ionian'],
			'melodic minor' => $this->MODES['melodic minor'],
			'harmonic minor' => $this->MODES['harmonic minor'],
			'harmonic major' => $this->MODES['harmonic major'],
			'double harmonic' => $this->MODES['double harmonic']
		);
		//
		$this->NON_MODAL_CHORDS = array(
			'min7b5',
			'dim7',
			'X'
		);
		//
	}
	// constructeur appelé par php4. 
	function MusicTheory(){
		$this->__construct();
	}
	//
}
?>